/* : pcb_defs.h,v 2.28 94/01/12 14:13:08 wikfors Exp $ */


/***********************************************************************/
/* INCLUDE FILE NAME:                                                  */
/* ==================                                                  */
/*                                                                     */
/* Author:                                                             */
/*                                                                     */
/* COMMENT:                                                            */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

#ifndef PCB_DEFS_H
#define PCB_DEFS_H

#define FWD_FLOW_NO_PRES   0
#define FWD_FLOW_BACK_PRES 1
#define FWD_PRES_NO_FLOW   2

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/

/* these two defines describe the voltage expected through the resistor divider sticks on the pcb2 */

#define PCB_ADC_OFFSET_STD           0x02d4   /*  ( 100 ohm * 10 volts / ( 18K+100 ohm ) ) * 65535 counts / 5 volts */
#define PCB_ADC_TEN_VOLT_STD         0xe38d   /*  ( 2.5k ohm * 10 volts / ( 2.5k+2k ohm ) ) * 65535 counts / 5 volts */

/* this is the value for the drooper-scooper divider stick on the +24v mainboard line */

     /* determined experimentally */
#define SIXTEEN_POINT_FIVE_VOLTS     0x6c00   /*  ( 16.5 / (38.3 + 1) * 10922 counts/volt + 0x8000 counts */


/* the following three constants describe the y=mx+b eq for the atmpres sensor */
/* they result from the solution of the eq    V = .198 + ( P-10 ) * 3.012 * 1.1 / 5  */

#define ATMP_OFFSET            ( Pneu_FPGA_Status != 1 ) ?                                                                  \
                                     1791    /* (10 * 68947.57 / 80) - ( 2.963 * ( 68947.57 / 80 ) / ( .374 ) ) */       :  \
                                     8188    /* (10 * 68947.57 / 80) - ( .301 * ( 68947.57 / 80 ) / ( 3.0125  / 5 ) ) */
#define ATMP_SCALE                  65536
#define ATMP_SLOPE             ( Pneu_FPGA_Status != 1 ) ?                                                                  \
                                    11522    /* ATMP_SCALE * ( 68947.57 / 80 ) / ( ( .374 ) * 13107 )  */                :  \
                                     7152    /* ATMP_SCALE * ( 68947.57 / 80 ) / ( ( 3.0125 / 5 ) * 13107 )  */

#define MAX_ALLOWED_ATM_PRES   ( Pneu_FPGA_Status != 1 ) ?                                                                  \
                               ((INT32)(15.5*68947.57/80))   /* 15.5 PSI A @ 80 dynes/cm2 per iu - needed with EOS baro sensor to stay in tables */ : \
                               ((INT32)(25.5*68947.57/80))   /* old sensor had no max, set limit well above max atmospheric pressure */
#define MIN_ALLOWED_ATM_PRES   ( Pneu_FPGA_Status != 1 ) ?                                                                  \
                               ((INT32)( 8.5*68947.57/80))   /* 8.5 PSI A @ 80 dynes/cm2 per iu - needed with EOS baro sensor to stay in tables */  : \
                               ((INT32)( 0.0*68947.57/80))   /* old sensor had no min, set limit to zero */


#define MAX_RETRY_COUNT              1


  /* definition of pcb return values */

#define SUCCESSFUL_TURN_ON           0x0001
#define SUCCESSFUL_TRANSFER          0x0001

#define COMMAND_NOT_UNDERSTOOD       0x2001
#define OUTPUT_BUFFER_OVERWRITE      0x2002
#define COMMAND_CHECKSUM_ERROR       0x2011
#define EEPROM_BUSY                  0x2020

#define FATAL_ADC_INVALID            0x2003
#define FATAL_PROGRAM_CHECKSUM       0x2008
#define FATAL_MEMORY_ERROR           0x200f
#define FATAL_PWM_DRIVE_ERROR        0x20f0
#define FATAL_REGISTER_TEST          0x20ff
#define FATAL_SAFETY_SHUTDOWN        0x2222   /* no communication with 331 for > 45 Sec */
#define FATAL_TIMESLOT_OVERRUN       0x2555




  /* definition of pcb command words */


#define DOWNLOAD_SETPOINTS           0x0001
#define DOWNLOAD_PID_TERMS           0x0002
#define PERFORM_SELF_TEST            0x0003
#define READ_EEPROM                  0x0004
#define WRITE_EEPROM                 0x0005
#define SET_FIXED_DUTY_CYCLE         0x0006
#define READ_DUTY_CYCLES             0x0007
#define RESTART_CHANNELS             0x0008
#define PEEK                         0x0009
#define POKE                         0x000a
#define REQUEST_ENVIRONMENT          0x000b
#define REQUEST_ICAP_CTRS            0x000c



  /* module numbers */

#define FRNT_INLET_MODULE_NUMBER     0x0000
#define BACK_INLET_MODULE_NUMBER     0x0001

#define FRNT_DETECTOR_MODULE_NUMBER  0x0002
#define BACK_DETECTOR_MODULE_NUMBER  0x0003

#define PNEU_AUX_MODULE_NUMBER       0x0004


  /* definition of pcb channel numbers */

#define FRNT_INLET_PRESSURE_CHANNEL  0
#define FRNT_INLET_FLOW_CHANNEL      1
#define BACK_INLET_PRESSURE_CHANNEL  2
#define BACK_INLET_FLOW_CHANNEL      3
#define FRNT_DETECTOR_GAS_1_CHANNEL  4
#define FRNT_DETECTOR_GAS_2_CHANNEL  5
#define FRNT_DETECTOR_GAS_3_CHANNEL  6
#define BACK_DETECTOR_GAS_1_CHANNEL  7
#define BACK_DETECTOR_GAS_2_CHANNEL  8
#define BACK_DETECTOR_GAS_3_CHANNEL  9
#define AUX_3_CHANNEL                10
#define AUX_4_CHANNEL                11
#define AUX_5_CHANNEL                12
#define FRNT_ALTERNATE_CHANNEL       13
#define BACK_ALTERNATE_CHANNEL       14

  /* buffer index for setpoints, actuals, and duty cycles */


#define SHUTDOWN_MASK_INDEX          1
#define FPR_BPR_MASK_INDEX           1
#define FRNT_INLET_PRESSURE_INDEX    2
#define FRNT_INLET_FLOW_INDEX        3
#define BACK_INLET_PRESSURE_INDEX    4
#define BACK_INLET_FLOW_INDEX        5
#define FRNT_DETECTOR_GAS_1_INDEX    6
#define FRNT_DETECTOR_GAS_2_INDEX    7
#define FRNT_DETECTOR_GAS_3_INDEX    8
#define BACK_DETECTOR_GAS_1_INDEX    9
#define BACK_DETECTOR_GAS_2_INDEX    10
#define BACK_DETECTOR_GAS_3_INDEX    11
#define AUX_3_INDEX                  12
#define AUX_4_INDEX                  13
#define AUX_5_INDEX                  14

#define FIRST_CHANNEL_INDEX          2


#define FRNT_INLET_MODULE_TEMP_INDEX 2
#define BACK_INLET_MODULE_TEMP_INDEX 3
#define FRNT_DET_MODULE_TEMP_INDEX   4
#define BACK_DET_MODULE_TEMP_INDEX   5
#define PNEU_AUX_MODULE_TEMP_INDEX   6
#define ATM_PRES_INDEX               7
#define PNEU_ADC_10V_INDEX           8
#define PNEU_ADC_OFFSET_INDEX        9
#define FRNT_INLET_GAS_ID_INDEX     10
#define BACK_INLET_GAS_ID_INDEX     11
#define PNEU_24V_INDEX              12



  /* mask definitions */

#define ALL_CHANNEL_MASK             0x1fff

#define FRNT_INLET_PRESSURE_MASK     0x0001
#define FRNT_INLET_FLOW_MASK         0x0002
#define BACK_INLET_PRESSURE_MASK     0x0004
#define BACK_INLET_FLOW_MASK         0x0008
#define FRNT_DETECTOR_GAS_1_MASK     0x0010
#define FRNT_DETECTOR_GAS_2_MASK     0x0020
#define FRNT_DETECTOR_GAS_3_MASK     0x0040
#define BACK_DETECTOR_GAS_1_MASK     0x0080
#define BACK_DETECTOR_GAS_2_MASK     0x0100
#define BACK_DETECTOR_GAS_3_MASK     0x0200
#define AUX_3_MASK                   0x0400
#define AUX_4_MASK                   0x0800
#define AUX_5_MASK                   0x1000

#define nFRNT_INLET_PRESSURE_MASK    (~FRNT_INLET_PRESSURE_MASK    )
#define nFRNT_INLET_FLOW_MASK        (~FRNT_INLET_FLOW_MASK        )
#define nBACK_INLET_PRESSURE_MASK    (~BACK_INLET_PRESSURE_MASK    )
#define nBACK_INLET_FLOW_MASK        (~BACK_INLET_FLOW_MASK        )
#define nFRNT_DETECTOR_GAS_1_MASK    (~FRNT_DETECTOR_GAS_1_MASK    )
#define nFRNT_DETECTOR_GAS_2_MASK    (~FRNT_DETECTOR_GAS_2_MASK    )
#define nFRNT_DETECTOR_GAS_3_MASK    (~FRNT_DETECTOR_GAS_3_MASK    )
#define nBACK_DETECTOR_GAS_1_MASK    (~BACK_DETECTOR_GAS_1_MASK    )
#define nBACK_DETECTOR_GAS_2_MASK    (~BACK_DETECTOR_GAS_2_MASK    )
#define nBACK_DETECTOR_GAS_3_MASK    (~BACK_DETECTOR_GAS_3_MASK    )
#define nAUX_3_MASK                  (~AUX_3_MASK                  )
#define nAUX_4_MASK                  (~AUX_4_MASK                  )
#define nAUX_5_MASK                  (~AUX_5_MASK                  )

#define DEFAULT_RANGE                PSI_100
#define DEFAULT_PD_TERM              0x0006
#define DEFAULT_I_TERM               0x000c
#define DEFAULT_D_TERM               0x0006
#define DEFAULT_NL_TERM              1
#define DEFAULT_NL_THRESHOLD         0x7fff


  /*********************************/
  /*  factory  eeprom definitions  */
  /*********************************/

   /* columnar positions for ranges and pid terms */

#define INLET_P_SENSOR           1
#define INLET_F_SENSOR           2
#define INLET_BBPR               3
#define INLET_ALTERNATE          3  /* alternate pids for inlet only */
#define GAS_1_SENSOR             1
#define GAS_2_SENSOR             2
#define GAS_3_SENSOR             3


#define             REQUIRED_AUX_VERSION     0x0200
#define             REQUIRED_DET_VERSION     0x0200
#define             REQUIRED_INLET_VERSION   0x0201


  /* standard eeprom header definitions */

#define TEST_STATION_ID          0xff        /* a hard eeprom address! */


/* location and size of CPF info stored in EEPROM */
#define  INLET_NAME_ADDR  0xFC
#define  INLET_NAME_SIZE  6

#define  DET_NAME_ADDR  0xFC
#define  DET_NAME_SIZE  6

#define  GAS1_LABEL_ADDR  0xCC
#define  GAS1_LABEL_SIZE  8
#define  GAS2_LABEL_ADDR  0xD0
#define  GAS2_LABEL_SIZE  8
#define  GAS3_LABEL_ADDR  0xD4
#define  GAS3_LABEL_SIZE  8

#define  NUM_DET_GAS      3    /* number of gas channels on detector pneumatics module */
#define  NUM_OIM_CHAN     4    /* number of control channels for OIM board */


#define  CTL1_LABEL_ADDR  0xD8
#define  CTL1_LABEL_SIZE  12
#define  CTL2_LABEL_ADDR  0xDE
#define  CTL2_LABEL_SIZE  12
#define  CTL3_LABEL_ADDR  0xE4
#define  CTL3_LABEL_SIZE  12
#define  CTL4_LABEL_ADDR  0xEA
#define  CTL4_LABEL_SIZE  12

#define  CTL5_LABEL_ADDR  0x60
#define  CTL5_LABEL_SIZE  12
#define  XTL6_LABEL_ADDR  0x66
#define  XTL6_LABEL_SIZE  12    /* If xtl6 & 7 are to share the same line then max size is 7 chars */
#define  XTL7_LABEL_ADDR  0x6C
#define  XTL7_LABEL_SIZE  12    /* If xtl6 & 7 are to share the same line then max size is 7 chars */


#define CTL1_2_PULSE_ADDR 0x72  /* ctl2 @ bits 15...8  , ctl1 @ bits 7...0 */
#define CTL3_4_PULSE_ADDR 0x73  /* ctl4 @ bits 15...8  , ctl3 @ bits 7...0 */
#define CTL5_PULSE_ADDR   0x74  /* null @ bits 15...8  , ctl5 @ bits 7...0 */

#define OEM_GC_LABEL_ADDR 0x75
#define OEM_GC_LABEL_SIZE 20

                              /* for OEM_DIAG1, OEM_DIAG2 inputs , the below 'MPY_DVD & OFFSET    */
                              /* addresses support scaling as follows:                            */
                              /*                                                                  */
                              /*   y = mult*( ( x - offset ) / dvdr )                             */
                              /*                                                                  */
                              /* where "x" above is the filtered diagnostic_X reading             */
                              /*       and the division is done BEFORE the multiplication         */
                              /*                                                                  */

#define OEM_DIAG1_LABEL_ADDR 0x7F
#define OEM_DIAG1_LABEL_SIZE 12      /* 6 ints = 12 chars                   default ="Diagnostic 1" */
#define OEM_DIAG1_MPY_DVD_ADDR 0xC6
                                 /* 16 bits                                                         */
                                 /* bits 15...8  = mult; unsigned; numerator for scaling; default=1 */
                                 /* bits 7...0 = dvdr; unsigned; denominator for scaling; default=1 */
#define OEM_DIAG1_OFFSET_ADDR 0xC3   /* 16 bit 2's complement                             default=0 */
#define OEM_DIAG1_OFFSET_SIZE 2
#define OEM_DIAG2_LABEL_ADDR 0x85
#define OEM_DIAG2_LABEL_SIZE 12      /* 6 ints = 12 chars                   default ="Diagnostic 2" */
#define OEM_DIAG2_MPY_DVD_ADDR 0xC0
                                 /* 16 bits                                                         */
                                 /* bits 15...8  = mult; unsigned; numerator for scaling; default=1 */
                                 /* bits 7...0 = dvdr; unsigned; denominator for scaling; default=1 */
#define OEM_DIAG2_OFFSET_ADDR 0xBD  /* 16 bit 2's complement                              default=0 */
#define OEM_DIAG2_OFFSET_SIZE 2

#define OEM_RDY_DIAG_FILTER_ADDR 0xBA
                              /* bits 15...12 = diag2 filter feedback multiplier = "dfm2"         */
                              /* bits 11... 8 = diag1 filter feedback multiplier = "dfm1"         */
                              /* bits   7...0 = POLL PERIOD                                       */
                              /*                                                                  */
                              /*                                                                  */
                              /*                                                                  */
                              /*                                                                  */
                              /* POLL_PERIOD =                                                    */
                              /*   K, K=0...255  => poll once every K seconds                     */
                              /*   0             => no polling; OEM card always ready             */
                              /*                                                                  */
                              /* See note 1 below for polling details                             */
                              /*                                                                  */
                              /*                                                                  */
                              /*                                                                  */
                              /*                                                                  */
                              /* Filtering for Diagnositic inputs 1,2 as follows:                 */
                              /*                                                                  */
                              /* Filtered_Diagnostic_X(N) = [   kX * Filtered_Diagnostic_X(N-1)   */
                              /*                             +(256-kX) * Diagnostic_X(N) ] / 256  */
                              /* where                                                            */
                              /*                                                                  */
                              /*    0 <= dfmX <= 15 ; default = 0 , i.e. no filtering             */
                              /*    and kX = 16*dfmX                                              */
                              /*                                                                  */

#define  CTL1_2_BITS_ADDR 0xF0
#define  CTL3_4_BITS_ADDR 0xF1

#define  CPF_PNEU_ADDR    0xF5

#define THERMAL_ADDR      0xF6
#define THERMAL_SIZE      0x06

#define THERMAL_WORD1_ADDR  0xF6
#define THERMAL_WORD2_ADDR  0xF7
#define THERMAL_WORD3_ADDR  0xF8
#define THERMAL_WORD4_ADDR  0xF9
#define THERMAL_WORD5_ADDR  0xFA
#define THERMAL_WORD6_ADDR  0xFB

#define HEADER_START             0x00
#define HEADER_SIZE              ( 3 * 3 )  /* three rows time three columns */

#define CHECKSUM                 ( 0x00 )

#define VERSION                  ( HEADER_START + 1 )
#define TYPE                     ( HEADER_START + 2 )

#define BUILD_DATE               ( HEADER_START + 3 )
#define SERIAL_NO_HIGH           ( HEADER_START + 4 )
#define SERIAL_NO_LOW            ( HEADER_START + 5 )

#define THERMISTOR_dV            ( HEADER_START + 6 )
#define THERMISTOR_dT            ( HEADER_START + 7 )
#define THERMISTOR_V_25C         ( HEADER_START + 8 )


   /* pressure sensor definitions  */

#define SENSOR_DEF_START         ( HEADER_START + HEADER_SIZE )
#define SENSOR_DEF_SIZE          ( 5 * 3 )

#define PS_RANGE                 ( SENSOR_DEF_START   )
#define PS_OFFSET                ( SENSOR_DEF_START + 3 )
#define PS_DOFFSET_DT            ( SENSOR_DEF_START + 6 )
#define PS_SPAN                  ( SENSOR_DEF_START + 9 )
#define PS_DSPAN_DT              ( SENSOR_DEF_START + 12 )

#define FS_AUTO_ZERO_DELAY       ( SENSOR_DEF_START + 12 + 1 )   /* just kludged in, last location in fs column */

  /* internal unit scalings */

#define IU_SCALE_START           ( SENSOR_DEF_START + SENSOR_DEF_SIZE )
#define IU_SCALE_SIZE            ( 2 * 3 )

#define P_SCALING                ( IU_SCALE_START )
#define F_SCALING                ( IU_SCALE_START + 3 )


   /* user calib */

#define USER_CALIB_START         ( IU_SCALE_START + IU_SCALE_SIZE )
#define USER_CALIB_SIZE          ( 4 * 3 )

#define USER_CALIB_STATE         ( USER_CALIB_START     )
#define USER_CALIB_DATE1         ( USER_CALIB_START + 1 )
#define USER_CALIB_DATE2         ( USER_CALIB_START + 2 )

#define USER_POS_1_OFFSET        ( USER_CALIB_START + 3 )
#define USER_POS_2_OFFSET        ( USER_CALIB_START + 4 )
#define USER_POS_3_OFFSET        ( USER_CALIB_START + 5 )

#define USER_POS_1_GAIN          ( USER_CALIB_START + 6 )
#define USER_POS_2_GAIN          ( USER_CALIB_START + 7 )
#define USER_POS_3_GAIN          ( USER_CALIB_START + 8 )

#define USER_POS_1_VALUE         ( USER_CALIB_START + 9 )
#define USER_POS_2_VALUE         ( USER_CALIB_START + 10 )
#define USER_POS_3_VALUE         ( USER_CALIB_START + 11 )


   /* factory calib */

#define FACTORY_CALIB_START      ( USER_CALIB_START + USER_CALIB_SIZE )
#define FACTORY_CALIB_SIZE       ( 2 * 3 )


#define FACTORY_POS_1_GAIN       ( FACTORY_CALIB_START   )
#define FACTORY_POS_2_GAIN       ( FACTORY_CALIB_START + 1 )
#define FACTORY_POS_3_GAIN       ( FACTORY_CALIB_START + 2 )

#define FACTORY_POS_1_OFFSET     ( FACTORY_CALIB_START + 3 )
#define FACTORY_POS_2_OFFSET     ( FACTORY_CALIB_START + 4 )
#define FACTORY_POS_3_OFFSET     ( FACTORY_CALIB_START + 5 )




#define FACT_PID_START           ( FACTORY_CALIB_START + FACTORY_CALIB_SIZE )


/* now map out the start positions of the various blocks for */
/* the detector temp comp parameters                         */

#define PID_BLOCK_SIZE           ( 4 * 3 )   /* four rows of three columns */

#define FACT_PID_SIZE            ( 4 * PID_BLOCK_SIZE )   /* 3 channels * 4 gases per channel * 4 pids per channel */

#define F_PID_BLOCK1_START         ( FACT_PID_START  )
#define F_PID_BLOCK2_START         ( FACT_PID_START   + PID_BLOCK_SIZE )
#define F_PID_BLOCK3_START         ( F_PID_BLOCK2_START + PID_BLOCK_SIZE )
#define F_PID_BLOCK4_START         ( F_PID_BLOCK3_START + PID_BLOCK_SIZE )

  /* define columnar positions */

#define PID_COL1                 ( 0 )
#define PID_COL2                 ( 1 )
#define PID_COL3                 ( 2 )

  /* define the word positioning relative tot he start of the block */

#define I_GAIN            ( 0 )
#define P_GAIN            ( 3 )
#define D_GAIN            ( 6 )
#define NL_GAIN           ( 9 )

/** Pres for inlets, fuel for dets **/


#define FACT_CH_1_N2_I_GAIN       ( F_PID_BLOCK1_START + PID_COL1 + I_GAIN )
#define FACT_CH_1_N2_P_GAIN       ( F_PID_BLOCK1_START + PID_COL1 + P_GAIN )
#define FACT_CH_1_N2_D_GAIN       ( F_PID_BLOCK1_START + PID_COL1 + D_GAIN )
#define FACT_CH_1_N2_NL_GAIN      ( F_PID_BLOCK1_START + PID_COL1 + NL_GAIN )

#define FACT_CH_1_H2_I_GAIN       ( F_PID_BLOCK2_START + PID_COL1 + I_GAIN )
#define FACT_CH_1_H2_P_GAIN       ( F_PID_BLOCK2_START + PID_COL1 + P_GAIN )
#define FACT_CH_1_H2_D_GAIN       ( F_PID_BLOCK2_START + PID_COL1 + D_GAIN )
#define FACT_CH_1_H2_NL_GAIN      ( F_PID_BLOCK2_START + PID_COL1 + NL_GAIN )

#define FACT_CH_1_He_I_GAIN       ( F_PID_BLOCK3_START + PID_COL1 + I_GAIN )
#define FACT_CH_1_He_P_GAIN       ( F_PID_BLOCK3_START + PID_COL1 + P_GAIN )
#define FACT_CH_1_He_D_GAIN       ( F_PID_BLOCK3_START + PID_COL1 + D_GAIN )
#define FACT_CH_1_He_NL_GAIN      ( F_PID_BLOCK3_START + PID_COL1 + NL_GAIN )

#define FACT_CH_1_ArMe_I_GAIN     ( F_PID_BLOCK4_START + PID_COL1 + I_GAIN )
#define FACT_CH_1_ArMe_P_GAIN     ( F_PID_BLOCK4_START + PID_COL1 + P_GAIN )
#define FACT_CH_1_ArMe_D_GAIN     ( F_PID_BLOCK4_START + PID_COL1 + D_GAIN )
#define FACT_CH_1_ArMe_NL_GAIN    ( F_PID_BLOCK4_START + PID_COL1 + NL_GAIN )

/** Flow for inlets, util for dets **/

   /* air and N2 share a block */

#define FACT_CH_2_Air_I_GAIN      ( F_PID_BLOCK1_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_Air_P_GAIN      ( F_PID_BLOCK1_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_Air_D_GAIN      ( F_PID_BLOCK1_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_Air_NL_GAIN     ( F_PID_BLOCK1_START + PID_COL2 + NL_GAIN )

#define FACT_CH_2_N2_I_GAIN       ( F_PID_BLOCK1_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_N2_P_GAIN       ( F_PID_BLOCK1_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_N2_D_GAIN       ( F_PID_BLOCK1_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_N2_NL_GAIN      ( F_PID_BLOCK1_START + PID_COL2 + NL_GAIN )


  /* H2 gets it's own block */

#define FACT_CH_2_H2_I_GAIN       ( F_PID_BLOCK2_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_H2_P_GAIN       ( F_PID_BLOCK2_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_H2_D_GAIN       ( F_PID_BLOCK2_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_H2_NL_GAIN      ( F_PID_BLOCK2_START + PID_COL2 + NL_GAIN )


  /* He and O2 share a block */

#define FACT_CH_2_O2_I_GAIN       ( F_PID_BLOCK3_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_O2_P_GAIN       ( F_PID_BLOCK3_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_O2_D_GAIN       ( F_PID_BLOCK3_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_O2_NL_GAIN      ( F_PID_BLOCK3_START + PID_COL2 + NL_GAIN )

#define FACT_CH_2_He_I_GAIN       ( F_PID_BLOCK3_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_He_P_GAIN       ( F_PID_BLOCK3_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_He_D_GAIN       ( F_PID_BLOCK3_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_He_NL_GAIN      ( F_PID_BLOCK3_START + PID_COL2 + NL_GAIN )


  /* Ar and ArMe share a block */

#define FACT_CH_2_ArMe_I_GAIN     ( F_PID_BLOCK4_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_ArMe_P_GAIN     ( F_PID_BLOCK4_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_ArMe_D_GAIN     ( F_PID_BLOCK4_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_ArMe_NL_GAIN    ( F_PID_BLOCK4_START + PID_COL2 + NL_GAIN )

#define FACT_CH_2_Ar_I_GAIN       ( F_PID_BLOCK4_START + PID_COL2 + I_GAIN )
#define FACT_CH_2_Ar_P_GAIN       ( F_PID_BLOCK4_START + PID_COL2 + P_GAIN )
#define FACT_CH_2_Ar_D_GAIN       ( F_PID_BLOCK4_START + PID_COL2 + D_GAIN )
#define FACT_CH_2_Ar_NL_GAIN      ( F_PID_BLOCK4_START + PID_COL2 + NL_GAIN )

/** Mug for dets,  Alt for inlets **/

#define FACT_CH_3_N2_I_GAIN       ( F_PID_BLOCK1_START + PID_COL3 + I_GAIN )
#define FACT_CH_3_N2_P_GAIN       ( F_PID_BLOCK1_START + PID_COL3 + P_GAIN )
#define FACT_CH_3_N2_D_GAIN       ( F_PID_BLOCK1_START + PID_COL3 + D_GAIN )
#define FACT_CH_3_N2_NL_GAIN      ( F_PID_BLOCK1_START + PID_COL3 + NL_GAIN )


#define FACT_CH_3_H2_I_GAIN       ( F_PID_BLOCK2_START + PID_COL3 + I_GAIN )
#define FACT_CH_3_H2_P_GAIN       ( F_PID_BLOCK2_START + PID_COL3 + P_GAIN )
#define FACT_CH_3_H2_D_GAIN       ( F_PID_BLOCK2_START + PID_COL3 + D_GAIN )
#define FACT_CH_3_H2_NL_GAIN      ( F_PID_BLOCK2_START + PID_COL3 + NL_GAIN )


#define FACT_CH_3_He_I_GAIN       ( F_PID_BLOCK3_START + PID_COL3 + I_GAIN )
#define FACT_CH_3_He_P_GAIN       ( F_PID_BLOCK3_START + PID_COL3 + P_GAIN )
#define FACT_CH_3_He_D_GAIN       ( F_PID_BLOCK3_START + PID_COL3 + D_GAIN )
#define FACT_CH_3_He_NL_GAIN      ( F_PID_BLOCK3_START + PID_COL3 + NL_GAIN )


#define FACT_CH_3_ArMe_I_GAIN     ( F_PID_BLOCK4_START + PID_COL3 + I_GAIN )
#define FACT_CH_3_ArMe_P_GAIN     ( F_PID_BLOCK4_START + PID_COL3 + P_GAIN )
#define FACT_CH_3_ArMe_D_GAIN     ( F_PID_BLOCK4_START + PID_COL3 + D_GAIN )
#define FACT_CH_3_ArMe_NL_GAIN    ( F_PID_BLOCK4_START + PID_COL3 + NL_GAIN )

#define FACT_CH_3_Ar_I_GAIN       ( F_PID_BLOCK4_START + PID_COL3 + I_GAIN )
#define FACT_CH_3_Ar_P_GAIN       ( F_PID_BLOCK4_START + PID_COL3 + P_GAIN )
#define FACT_CH_3_Ar_D_GAIN       ( F_PID_BLOCK4_START + PID_COL3 + D_GAIN )
#define FACT_CH_3_Ar_NL_GAIN      ( F_PID_BLOCK4_START + PID_COL3 + NL_GAIN )





#define USER_PID_START           ( FACT_PID_START + FACT_PID_SIZE )


/* now map out the start positions of the various blocks for */
/* the detector temp comp parameters                         */

#define PID_BLOCK_SIZE           ( 4 * 3 )   /* four rows of three columns */

#define USER_PID_SIZE            ( 4 * PID_BLOCK_SIZE )   /* 3 channels * 4 gases per channel * 4 pids per channel */

#define U_PID_BLOCK1_START         ( USER_PID_START  )
#define U_PID_BLOCK2_START         ( USER_PID_START   + PID_BLOCK_SIZE )
#define U_PID_BLOCK3_START         ( U_PID_BLOCK2_START + PID_BLOCK_SIZE )
#define U_PID_BLOCK4_START         ( U_PID_BLOCK3_START + PID_BLOCK_SIZE )

  /* define columnar positions */

#define PID_COL1                 ( 0 )
#define PID_COL2                 ( 1 )
#define PID_COL3                 ( 2 )

  /* define the word positioning relative tot he start of the block */

#define I_GAIN            ( 0 )
#define P_GAIN            ( 3 )
#define D_GAIN            ( 6 )
#define NL_GAIN           ( 9 )


/** Pres for inlets, fuel for dets **/


#define USER_CH_1_N2_I_GAIN       ( U_PID_BLOCK1_START + PID_COL1 + I_GAIN )
#define USER_CH_1_N2_P_GAIN       ( U_PID_BLOCK1_START + PID_COL1 + P_GAIN )
#define USER_CH_1_N2_D_GAIN       ( U_PID_BLOCK1_START + PID_COL1 + D_GAIN )
#define USER_CH_1_N2_NL_GAIN      ( U_PID_BLOCK1_START + PID_COL1 + NL_GAIN )

#define USER_CH_1_H2_I_GAIN       ( U_PID_BLOCK2_START + PID_COL1 + I_GAIN )
#define USER_CH_1_H2_P_GAIN       ( U_PID_BLOCK2_START + PID_COL1 + P_GAIN )
#define USER_CH_1_H2_D_GAIN       ( U_PID_BLOCK2_START + PID_COL1 + D_GAIN )
#define USER_CH_1_H2_NL_GAIN      ( U_PID_BLOCK2_START + PID_COL1 + NL_GAIN )

#define USER_CH_1_He_I_GAIN       ( U_PID_BLOCK3_START + PID_COL1 + I_GAIN )
#define USER_CH_1_He_P_GAIN       ( U_PID_BLOCK3_START + PID_COL1 + P_GAIN )
#define USER_CH_1_He_D_GAIN       ( U_PID_BLOCK3_START + PID_COL1 + D_GAIN )
#define USER_CH_1_He_NL_GAIN      ( U_PID_BLOCK3_START + PID_COL1 + NL_GAIN )

#define USER_CH_1_ArMe_I_GAIN     ( U_PID_BLOCK4_START + PID_COL1 + I_GAIN )
#define USER_CH_1_ArMe_P_GAIN     ( U_PID_BLOCK4_START + PID_COL1 + P_GAIN )
#define USER_CH_1_ArMe_D_GAIN     ( U_PID_BLOCK4_START + PID_COL1 + D_GAIN )
#define USER_CH_1_ArMe_NL_GAIN    ( U_PID_BLOCK4_START + PID_COL1 + NL_GAIN )

/** Flow for inlets, util for dets **/

   /* air and N2 share a block */

#define USER_CH_2_Air_I_GAIN      ( U_PID_BLOCK1_START + PID_COL2 + I_GAIN )
#define USER_CH_2_Air_P_GAIN      ( U_PID_BLOCK1_START + PID_COL2 + P_GAIN )
#define USER_CH_2_Air_D_GAIN      ( U_PID_BLOCK1_START + PID_COL2 + D_GAIN )
#define USER_CH_2_Air_NL_GAIN     ( U_PID_BLOCK1_START + PID_COL2 + NL_GAIN )

#define USER_CH_2_N2_I_GAIN       ( U_PID_BLOCK1_START + PID_COL2 + I_GAIN )
#define USER_CH_2_N2_P_GAIN       ( U_PID_BLOCK1_START + PID_COL2 + P_GAIN )
#define USER_CH_2_N2_D_GAIN       ( U_PID_BLOCK1_START + PID_COL2 + D_GAIN )
#define USER_CH_2_N2_NL_GAIN      ( U_PID_BLOCK1_START + PID_COL2 + NL_GAIN )


  /* H2 gets it's own block */

#define USER_CH_2_H2_I_GAIN       ( U_PID_BLOCK2_START + PID_COL2 + I_GAIN )
#define USER_CH_2_H2_P_GAIN       ( U_PID_BLOCK2_START + PID_COL2 + P_GAIN )
#define USER_CH_2_H2_D_GAIN       ( U_PID_BLOCK2_START + PID_COL2 + D_GAIN )
#define USER_CH_2_H2_NL_GAIN      ( U_PID_BLOCK2_START + PID_COL2 + NL_GAIN )


  /* He and O2 share a block */

#define USER_CH_2_O2_I_GAIN       ( U_PID_BLOCK3_START + PID_COL2 + I_GAIN )
#define USER_CH_2_O2_P_GAIN       ( U_PID_BLOCK3_START + PID_COL2 + P_GAIN )
#define USER_CH_2_O2_D_GAIN       ( U_PID_BLOCK3_START + PID_COL2 + D_GAIN )
#define USER_CH_2_O2_NL_GAIN      ( U_PID_BLOCK3_START + PID_COL2 + NL_GAIN )

#define USER_CH_2_He_I_GAIN       ( U_PID_BLOCK3_START + PID_COL2 + I_GAIN )
#define USER_CH_2_He_P_GAIN       ( U_PID_BLOCK3_START + PID_COL2 + P_GAIN )
#define USER_CH_2_He_D_GAIN       ( U_PID_BLOCK3_START + PID_COL2 + D_GAIN )
#define USER_CH_2_He_NL_GAIN      ( U_PID_BLOCK3_START + PID_COL2 + NL_GAIN )


  /* Ar and ArMe share a block */

#define USER_CH_2_ArMe_I_GAIN     ( U_PID_BLOCK4_START + PID_COL2 + I_GAIN )
#define USER_CH_2_ArMe_P_GAIN     ( U_PID_BLOCK4_START + PID_COL2 + P_GAIN )
#define USER_CH_2_ArMe_D_GAIN     ( U_PID_BLOCK4_START + PID_COL2 + D_GAIN )
#define USER_CH_2_ArMe_NL_GAIN    ( U_PID_BLOCK4_START + PID_COL2 + NL_GAIN )

#define USER_CH_2_Ar_I_GAIN       ( U_PID_BLOCK4_START + PID_COL2 + I_GAIN )
#define USER_CH_2_Ar_P_GAIN       ( U_PID_BLOCK4_START + PID_COL2 + P_GAIN )
#define USER_CH_2_Ar_D_GAIN       ( U_PID_BLOCK4_START + PID_COL2 + D_GAIN )
#define USER_CH_2_Ar_NL_GAIN      ( U_PID_BLOCK4_START + PID_COL2 + NL_GAIN )

/** Mug for dets,  Alt for inlets **/

#define USER_CH_3_N2_I_GAIN       ( U_PID_BLOCK1_START + PID_COL3 + I_GAIN )
#define USER_CH_3_N2_P_GAIN       ( U_PID_BLOCK1_START + PID_COL3 + P_GAIN )
#define USER_CH_3_N2_D_GAIN       ( U_PID_BLOCK1_START + PID_COL3 + D_GAIN )
#define USER_CH_3_N2_NL_GAIN      ( U_PID_BLOCK1_START + PID_COL3 + NL_GAIN )


#define USER_CH_3_H2_I_GAIN       ( U_PID_BLOCK2_START + PID_COL3 + I_GAIN )
#define USER_CH_3_H2_P_GAIN       ( U_PID_BLOCK2_START + PID_COL3 + P_GAIN )
#define USER_CH_3_H2_D_GAIN       ( U_PID_BLOCK2_START + PID_COL3 + D_GAIN )
#define USER_CH_3_H2_NL_GAIN      ( U_PID_BLOCK2_START + PID_COL3 + NL_GAIN )


#define USER_CH_3_He_I_GAIN       ( U_PID_BLOCK3_START + PID_COL3 + I_GAIN )
#define USER_CH_3_He_P_GAIN       ( U_PID_BLOCK3_START + PID_COL3 + P_GAIN )
#define USER_CH_3_He_D_GAIN       ( U_PID_BLOCK3_START + PID_COL3 + D_GAIN )
#define USER_CH_3_He_NL_GAIN      ( U_PID_BLOCK3_START + PID_COL3 + NL_GAIN )


#define USER_CH_3_ArMe_I_GAIN     ( U_PID_BLOCK4_START + PID_COL3 + I_GAIN )
#define USER_CH_3_ArMe_P_GAIN     ( U_PID_BLOCK4_START + PID_COL3 + P_GAIN )
#define USER_CH_3_ArMe_D_GAIN     ( U_PID_BLOCK4_START + PID_COL3 + D_GAIN )
#define USER_CH_3_ArMe_NL_GAIN    ( U_PID_BLOCK4_START + PID_COL3 + NL_GAIN )

#define USER_CH_3_Ar_I_GAIN       ( U_PID_BLOCK4_START + PID_COL3 + I_GAIN )
#define USER_CH_3_Ar_P_GAIN       ( U_PID_BLOCK4_START + PID_COL3 + P_GAIN )
#define USER_CH_3_Ar_D_GAIN       ( U_PID_BLOCK4_START + PID_COL3 + D_GAIN )
#define USER_CH_3_Ar_NL_GAIN      ( U_PID_BLOCK4_START + PID_COL3 + NL_GAIN )



#define TEMP_COMP_START          ( USER_PID_START + USER_PID_SIZE )

/* now map out the start positions of the various blocks for */
/* the detector temp comp parameters                         */

#define DET_BLOCK_SIZE           ( 5 * 3 )   /* five rows of three columns */

#define DET_BLOCK1_START         ( TEMP_COMP_START )
#define DET_BLOCK2_START         ( TEMP_COMP_START  + DET_BLOCK_SIZE )
#define DET_BLOCK3_START         ( DET_BLOCK2_START + DET_BLOCK_SIZE )
#define DET_BLOCK4_START         ( DET_BLOCK3_START + DET_BLOCK_SIZE )

  /* define columnar positions */

#define DET_FUEL                 ( 0 )
#define DET_UTIL                 ( 1 )
#define DET_MUG                  ( 2 )

  /* define the word positioning relative to the start of the block */

#define FRIT_1_WORD_1            ( 0 )
#define FRIT_1_WORD_2            ( 3 )
#define FRIT_2_WORD_1            ( 6 )
#define FRIT_2_WORD_2            ( 9 )
#define DET_MAX_FLOW            ( 12 )

#define DET_MINS                 ( 0 )
#define CH2_MIN_FLOW            ( 12 )

/* detector frit and gas specific temp comp parameters */


#define GAS_1_H2_FRIT_1_WORD_1       ( DET_BLOCK1_START + DET_FUEL + FRIT_1_WORD_1 )
#define GAS_1_H2_FRIT_1_WORD_2       ( DET_BLOCK1_START + DET_FUEL + FRIT_1_WORD_2 )
#define GAS_1_H2_FRIT_2_WORD_1       ( DET_BLOCK1_START + DET_FUEL + FRIT_2_WORD_1 )
#define GAS_1_H2_FRIT_2_WORD_2       ( DET_BLOCK1_START + DET_FUEL + FRIT_2_WORD_2 )
#define GAS_1_H2_MAX_FLOW            ( DET_BLOCK1_START + DET_FUEL + DET_MAX_FLOW  )

/**********************************************************************************************************/

#define GAS_2_Air_FRIT_1_WORD_1      ( DET_BLOCK1_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_Air_FRIT_1_WORD_2      ( DET_BLOCK1_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_Air_FRIT_2_WORD_1      ( DET_BLOCK1_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_Air_FRIT_2_WORD_2      ( DET_BLOCK1_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_Air_MAX_FLOW           ( DET_BLOCK1_START + DET_UTIL + DET_MAX_FLOW  )

#define GAS_2_N2_FRIT_1_WORD_1       ( DET_BLOCK1_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_N2_FRIT_1_WORD_2       ( DET_BLOCK1_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_N2_FRIT_2_WORD_1       ( DET_BLOCK1_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_N2_FRIT_2_WORD_2       ( DET_BLOCK1_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_N2_MAX_FLOW            ( DET_BLOCK1_START + DET_UTIL + DET_MAX_FLOW  )

#define GAS_2_O2_FRIT_1_WORD_1       ( DET_BLOCK2_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_O2_FRIT_1_WORD_2       ( DET_BLOCK2_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_O2_FRIT_2_WORD_1       ( DET_BLOCK2_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_O2_FRIT_2_WORD_2       ( DET_BLOCK2_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_O2_MAX_FLOW            ( DET_BLOCK2_START + DET_UTIL + DET_MAX_FLOW  )

#define GAS_2_He_FRIT_1_WORD_1       ( DET_BLOCK2_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_He_FRIT_1_WORD_2       ( DET_BLOCK2_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_He_FRIT_2_WORD_1       ( DET_BLOCK2_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_He_FRIT_2_WORD_2       ( DET_BLOCK2_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_He_MAX_FLOW            ( DET_BLOCK2_START + DET_UTIL + DET_MAX_FLOW  )

#define GAS_2_ArMe_FRIT_1_WORD_1     ( DET_BLOCK3_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_ArMe_FRIT_1_WORD_2     ( DET_BLOCK3_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_ArMe_FRIT_2_WORD_1     ( DET_BLOCK3_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_ArMe_FRIT_2_WORD_2     ( DET_BLOCK3_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_ArMe_MAX_FLOW          ( DET_BLOCK3_START + DET_UTIL + DET_MAX_FLOW  )

#define GAS_2_H2_FRIT_1_WORD_1       ( DET_BLOCK3_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_H2_FRIT_1_WORD_2       ( DET_BLOCK3_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_H2_FRIT_2_WORD_1       ( DET_BLOCK3_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_H2_FRIT_2_WORD_2       ( DET_BLOCK3_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_H2_MAX_FLOW            ( DET_BLOCK3_START + DET_UTIL + DET_MAX_FLOW  )

#define GAS_2_Ar_FRIT_1_WORD_1       ( DET_BLOCK4_START + DET_UTIL + FRIT_1_WORD_1 )
#define GAS_2_Ar_FRIT_1_WORD_2       ( DET_BLOCK4_START + DET_UTIL + FRIT_1_WORD_2 )
#define GAS_2_Ar_FRIT_2_WORD_1       ( DET_BLOCK4_START + DET_UTIL + FRIT_2_WORD_1 )
#define GAS_2_Ar_FRIT_2_WORD_2       ( DET_BLOCK4_START + DET_UTIL + FRIT_2_WORD_2 )
#define GAS_2_Ar_MAX_FLOW            ( DET_BLOCK4_START + DET_UTIL + DET_MAX_FLOW  )

/**********************************************************************************************************/

#define GAS_3_N2_FRIT_1_WORD_1       ( DET_BLOCK1_START + DET_MUG  + FRIT_1_WORD_1 )
#define GAS_3_N2_FRIT_1_WORD_2       ( DET_BLOCK1_START + DET_MUG  + FRIT_1_WORD_2 )
#define GAS_3_N2_FRIT_2_WORD_1       ( DET_BLOCK1_START + DET_MUG  + FRIT_2_WORD_1 )
#define GAS_3_N2_FRIT_2_WORD_2       ( DET_BLOCK1_START + DET_MUG  + FRIT_2_WORD_2 )
#define GAS_3_N2_MAX_FLOW            ( DET_BLOCK1_START + DET_MUG  + DET_MAX_FLOW  )

#define GAS_3_He_FRIT_1_WORD_1       ( DET_BLOCK2_START + DET_MUG  + FRIT_1_WORD_1 )
#define GAS_3_He_FRIT_1_WORD_2       ( DET_BLOCK2_START + DET_MUG  + FRIT_1_WORD_2 )
#define GAS_3_He_FRIT_2_WORD_1       ( DET_BLOCK2_START + DET_MUG  + FRIT_2_WORD_1 )
#define GAS_3_He_FRIT_2_WORD_2       ( DET_BLOCK2_START + DET_MUG  + FRIT_2_WORD_2 )
#define GAS_3_He_MAX_FLOW            ( DET_BLOCK2_START + DET_MUG  + DET_MAX_FLOW  )

#define GAS_3_ArMe_FRIT_1_WORD_1     ( DET_BLOCK3_START + DET_MUG  + FRIT_1_WORD_1 )
#define GAS_3_ArMe_FRIT_1_WORD_2     ( DET_BLOCK3_START + DET_MUG  + FRIT_1_WORD_2 )
#define GAS_3_ArMe_FRIT_2_WORD_1     ( DET_BLOCK3_START + DET_MUG  + FRIT_2_WORD_1 )
#define GAS_3_ArMe_FRIT_2_WORD_2     ( DET_BLOCK3_START + DET_MUG  + FRIT_2_WORD_2 )
#define GAS_3_ArMe_MAX_FLOW          ( DET_BLOCK3_START + DET_MUG  + DET_MAX_FLOW  )

#define GAS_3_H2_FRIT_1_WORD_1       ( DET_BLOCK3_START + DET_MUG  + FRIT_1_WORD_1 )
#define GAS_3_H2_FRIT_1_WORD_2       ( DET_BLOCK3_START + DET_MUG  + FRIT_1_WORD_2 )
#define GAS_3_H2_FRIT_2_WORD_1       ( DET_BLOCK3_START + DET_MUG  + FRIT_2_WORD_1 )
#define GAS_3_H2_FRIT_2_WORD_2       ( DET_BLOCK3_START + DET_MUG  + FRIT_2_WORD_2 )
#define GAS_3_H2_MAX_FLOW            ( DET_BLOCK3_START + DET_MUG  + DET_MAX_FLOW  )

#define GAS_3_Ar_FRIT_1_WORD_1       ( DET_BLOCK4_START + DET_MUG  + FRIT_1_WORD_1 )
#define GAS_3_Ar_FRIT_1_WORD_2       ( DET_BLOCK4_START + DET_MUG  + FRIT_1_WORD_2 )
#define GAS_3_Ar_FRIT_2_WORD_1       ( DET_BLOCK4_START + DET_MUG  + FRIT_2_WORD_1 )
#define GAS_3_Ar_FRIT_2_WORD_2       ( DET_BLOCK4_START + DET_MUG  + FRIT_2_WORD_2 )
#define GAS_3_Ar_MAX_FLOW            ( DET_BLOCK4_START + DET_MUG  + DET_MAX_FLOW  )

#define GAS_2_MIN_FLOW               ( DET_BLOCK4_START + DET_MINS + CH2_MIN_FLOW  )


/**********************************************************************************************************/
/**********************************************************************************************************/
/**********************************************************************************************************/


/* now define the various gas blocks for inlets */

#define INLET_BLOCK_SIZE             ( 5 * 3 )
#define NUM_INLET_BLOCKS               4

#define H2_BLOCK                     ( TEMP_COMP_START )
#define HE_BLOCK                     ( H2_BLOCK + INLET_BLOCK_SIZE )
#define ARME_BLOCK                   ( HE_BLOCK + INLET_BLOCK_SIZE )
#define N2_BLOCK                     ( ARME_BLOCK + INLET_BLOCK_SIZE )

/* now define the block components */

#define ALPHA_LOW                    ( 0 )
#define BETA_LOW                     ( 1 )
#define SWITCH_FLOW                  ( 2 )
#define ALPHA_HIGH                   ( 3 )
#define BETA_HIGH                    ( 4 )
#define OFFSET                       ( 5 )
#define DALPHA                       ( 6 )
#define DBETA                        ( 7 )
#define DOFFSET                      ( 8 )
#define REF_TEMP                     ( 9 )
#define PURGE_REG_FLOW               ( 10 )
#define DPURGE_FLOW_DPRES            ( 11 )
#define MAX_INLET_FLOW               ( 12 )
#define CALIB_TEMP_1                 ( 13 )
#define CALIB_TEMP_2                 ( 14 )

  /* inlet specific temp comp parms */

#define H2_ALPHA_LOW                 ( H2_BLOCK + ALPHA_LOW   )
#define H2_ALPHA_HIGH                ( H2_BLOCK + ALPHA_HIGH  )
#define H2_BETA_LOW                  ( H2_BLOCK + BETA_LOW    )
#define H2_BETA_HIGH                 ( H2_BLOCK + BETA_HIGH   )
#define H2_OFFSET                    ( H2_BLOCK + OFFSET      )
#define H2_HIGH_FLOW                 ( H2_BLOCK + SWITCH_FLOW )
#define H2_dALPHA_dT                 ( H2_BLOCK + DALPHA      )
#define H2_dBETA_dT                  ( H2_BLOCK + DBETA       )
#define H2_dOFFSET_dT                ( H2_BLOCK + DOFFSET     )
#define H2_REF_TEMP                  ( H2_BLOCK + REF_TEMP    )
#define H2_PURGE_FLOW                ( H2_BLOCK + PURGE_REG_FLOW )
#define H2_dPURGE_dP                 ( H2_BLOCK + DPURGE_FLOW_DPRES )
#define H2_MAX_INLET_FLOW            ( H2_BLOCK + MAX_INLET_FLOW    )
#define H2_CALIB_TEMP_1              ( H2_BLOCK + CALIB_TEMP_1)
#define H2_CALIB_TEMP_2              ( H2_BLOCK + CALIB_TEMP_2)

#define He_ALPHA_LOW                 ( HE_BLOCK + ALPHA_LOW   )
#define He_ALPHA_HIGH                ( HE_BLOCK + ALPHA_HIGH  )
#define He_BETA_LOW                  ( HE_BLOCK + BETA_LOW    )
#define He_BETA_HIGH                 ( HE_BLOCK + BETA_HIGH   )
#define He_OFFSET                    ( HE_BLOCK + OFFSET      )
#define He_HIGH_FLOW                 ( HE_BLOCK + SWITCH_FLOW )
#define He_dALPHA_dT                 ( HE_BLOCK + DALPHA      )
#define He_dBETA_dT                  ( HE_BLOCK + DBETA       )
#define He_dOFFSET_dT                ( HE_BLOCK + DOFFSET     )
#define He_REF_TEMP                  ( HE_BLOCK + REF_TEMP    )
#define He_PURGE_FLOW                ( HE_BLOCK + PURGE_REG_FLOW )
#define He_dPURGE_dP                 ( HE_BLOCK + DPURGE_FLOW_DPRES )
#define He_MAX_INLET_FLOW            ( HE_BLOCK + MAX_INLET_FLOW    )
#define He_CALIB_TEMP_1              ( HE_BLOCK + CALIB_TEMP_1)
#define He_CALIB_TEMP_2              ( HE_BLOCK + CALIB_TEMP_2)

#define N2_ALPHA_LOW                 ( N2_BLOCK + ALPHA_LOW   )
#define N2_ALPHA_HIGH                ( N2_BLOCK + ALPHA_HIGH  )
#define N2_BETA_LOW                  ( N2_BLOCK + BETA_LOW    )
#define N2_BETA_HIGH                 ( N2_BLOCK + BETA_HIGH   )
#define N2_OFFSET                    ( N2_BLOCK + OFFSET      )
#define N2_HIGH_FLOW                 ( N2_BLOCK + SWITCH_FLOW )
#define N2_dALPHA_dT                 ( N2_BLOCK + DALPHA      )
#define N2_dBETA_dT                  ( N2_BLOCK + DBETA       )
#define N2_dOFFSET_dT                ( N2_BLOCK + DOFFSET     )
#define N2_REF_TEMP                  ( N2_BLOCK + REF_TEMP    )
#define N2_PURGE_FLOW                ( N2_BLOCK + PURGE_REG_FLOW )
#define N2_dPURGE_dP                 ( N2_BLOCK + DPURGE_FLOW_DPRES )
#define N2_MAX_INLET_FLOW            ( N2_BLOCK + MAX_INLET_FLOW    )
#define N2_CALIB_TEMP_1              ( N2_BLOCK + CALIB_TEMP_1)
#define N2_CALIB_TEMP_2              ( N2_BLOCK + CALIB_TEMP_2)

#define ArMe_ALPHA_LOW               ( ARME_BLOCK + ALPHA_LOW   )
#define ArMe_ALPHA_HIGH              ( ARME_BLOCK + ALPHA_HIGH  )
#define ArMe_BETA_LOW                ( ARME_BLOCK + BETA_LOW    )
#define ArMe_BETA_HIGH               ( ARME_BLOCK + BETA_HIGH   )
#define ArMe_OFFSET                  ( ARME_BLOCK + OFFSET      )
#define ArMe_HIGH_FLOW               ( ARME_BLOCK + SWITCH_FLOW )
#define ArMe_dALPHA_dT               ( ARME_BLOCK + DALPHA      )
#define ArMe_dBETA_dT                ( ARME_BLOCK + DBETA       )
#define ArMe_dOFFSET_dT              ( ARME_BLOCK + DOFFSET     )
#define ArMe_REF_TEMP                ( ARME_BLOCK + REF_TEMP    )
#define ArMe_PURGE_FLOW              ( ARME_BLOCK + PURGE_REG_FLOW )
#define ArMe_dPURGE_dP               ( ARME_BLOCK + DPURGE_FLOW_DPRES )
#define ArMe_MAX_INLET_FLOW          ( ARME_BLOCK + MAX_INLET_FLOW    )
#define ArMe_CALIB_TEMP_1            ( ARME_BLOCK + CALIB_TEMP_1)
#define ArMe_CALIB_TEMP_2            ( ARME_BLOCK + CALIB_TEMP_2)



/**********************************************************************************************************/
/**********************************************************************************************************/
/**********************************************************************************************************/


/* now define the various gas blocks for inlets */

#define INLET_CALIB_BLOCK_SIZE        ( 3 * 3 )
#define NUM_INLET_CALIB_BLOCKS          4

#define INLET_FLOW_CALIB_START         ( TEMP_COMP_START +( INLET_BLOCK_SIZE * NUM_INLET_BLOCKS ) )

#define H2_CALIB_BLOCK                     ( INLET_FLOW_CALIB_START )
#define He_CALIB_BLOCK                     ( H2_CALIB_BLOCK   + INLET_CALIB_BLOCK_SIZE )
#define ArMe_CALIB_BLOCK                   ( He_CALIB_BLOCK   + INLET_CALIB_BLOCK_SIZE )
#define N2_CALIB_BLOCK                     ( ArMe_CALIB_BLOCK + INLET_CALIB_BLOCK_SIZE )


  /* these values are saved as part of normal inlet calibration */

#define CALIB_REF_FLOW                ( 0 )
#define CALIB_V0_T1                   ( 1 )
#define CALIB_V1_T1                   ( 2 )
#define CALIB_V3_T1                   ( 3 )
#define CALIB_V9_T1                   ( 4 )
#define CALIB_V0_T2                   ( 5 )
#define CALIB_V1_T2                   ( 6 )
#define CALIB_V3_T2                   ( 7 )
#define CALIB_V9_T2                   ( 8 )
#define CALIB_REF_TEMP_1              ( 9 )
#define CALIB_REF_TEMP_2              ( 10 )


#define H2_CALIB_REF_FLOW             ( H2_CALIB_BLOCK + CALIB_REF_FLOW )
#define H2_CALIB_V0_T1                ( H2_CALIB_BLOCK + CALIB_V0_T1 )
#define H2_CALIB_V1_T1                ( H2_CALIB_BLOCK + CALIB_V1_T1 )
#define H2_CALIB_V3_T1                ( H2_CALIB_BLOCK + CALIB_V3_T1 )
#define H2_CALIB_V9_T1                ( H2_CALIB_BLOCK + CALIB_V9_T1 )
#define H2_CALIB_V0_T2                ( H2_CALIB_BLOCK + CALIB_V0_T2 )
#define H2_CALIB_V1_T2                ( H2_CALIB_BLOCK + CALIB_V1_T2 )
#define H2_CALIB_V3_T2                ( H2_CALIB_BLOCK + CALIB_V3_T2 )
#define H2_CALIB_V9_T2                ( H2_CALIB_BLOCK + CALIB_V9_T2 )
#define H2_CALIB_T1                   ( H2_CALIB_TEMP_1 )
#define H2_CALIB_T2                   ( H2_CALIB_TEMP_2 )



#define He_CALIB_REF_FLOW             ( He_CALIB_BLOCK + CALIB_REF_FLOW )
#define He_CALIB_V0_T1                ( He_CALIB_BLOCK + CALIB_V0_T1 )
#define He_CALIB_V1_T1                ( He_CALIB_BLOCK + CALIB_V1_T1 )
#define He_CALIB_V3_T1                ( He_CALIB_BLOCK + CALIB_V3_T1 )
#define He_CALIB_V9_T1                ( He_CALIB_BLOCK + CALIB_V9_T1 )
#define He_CALIB_V0_T2                ( He_CALIB_BLOCK + CALIB_V0_T2 )
#define He_CALIB_V1_T2                ( He_CALIB_BLOCK + CALIB_V1_T2 )
#define He_CALIB_V3_T2                ( He_CALIB_BLOCK + CALIB_V3_T2 )
#define He_CALIB_V9_T2                ( He_CALIB_BLOCK + CALIB_V9_T2 )
#define He_CALIB_T1                   ( He_CALIB_TEMP_1 )
#define He_CALIB_T2                   ( He_CALIB_TEMP_2 )


#define ArMe_CALIB_REF_FLOW           ( ArMe_CALIB_BLOCK + CALIB_REF_FLOW )
#define ArMe_CALIB_V0_T1              ( ArMe_CALIB_BLOCK + CALIB_V0_T1 )
#define ArMe_CALIB_V1_T1              ( ArMe_CALIB_BLOCK + CALIB_V1_T1 )
#define ArMe_CALIB_V3_T1              ( ArMe_CALIB_BLOCK + CALIB_V3_T1 )
#define ArMe_CALIB_V9_T1              ( ArMe_CALIB_BLOCK + CALIB_V9_T1 )
#define ArMe_CALIB_V0_T2              ( ArMe_CALIB_BLOCK + CALIB_V0_T2 )
#define ArMe_CALIB_V1_T2              ( ArMe_CALIB_BLOCK + CALIB_V1_T2 )
#define ArMe_CALIB_V3_T2              ( ArMe_CALIB_BLOCK + CALIB_V3_T2 )
#define ArMe_CALIB_V9_T2              ( ArMe_CALIB_BLOCK + CALIB_V9_T2 )
#define ArMe_CALIB_T1                 ( ArMe_CALIB_TEMP_1 )
#define ArMe_CALIB_T2                 ( ArMe_CALIB_TEMP_2 )


#define N2_CALIB_REF_FLOW             ( N2_CALIB_BLOCK + CALIB_REF_FLOW )
#define N2_CALIB_V0_T1                ( N2_CALIB_BLOCK + CALIB_V0_T1 )
#define N2_CALIB_V1_T1                ( N2_CALIB_BLOCK + CALIB_V1_T1 )
#define N2_CALIB_V3_T1                ( N2_CALIB_BLOCK + CALIB_V3_T1 )
#define N2_CALIB_V9_T1                ( N2_CALIB_BLOCK + CALIB_V9_T1 )
#define N2_CALIB_V0_T2                ( N2_CALIB_BLOCK + CALIB_V0_T2 )
#define N2_CALIB_V1_T2                ( N2_CALIB_BLOCK + CALIB_V1_T2 )
#define N2_CALIB_V3_T2                ( N2_CALIB_BLOCK + CALIB_V3_T2 )
#define N2_CALIB_V9_T2                ( N2_CALIB_BLOCK + CALIB_V9_T2 )
#define N2_CALIB_T1                   ( N2_CALIB_TEMP_1 )
#define N2_CALIB_T2                   ( N2_CALIB_TEMP_2 )

/**********************************************************************************************************/
/**********************************************************************************************************/



/* now define the various gas blocks for inlets */

#define INLET_AUTO_CAL_BLOCK_SIZE        ( 1 )
#define NUM_INLET_AUTO_CAL_BLOCKS          6

#define INLET_AUTO_CAL_START         ( INLET_FLOW_CALIB_START +( INLET_CALIB_BLOCK_SIZE * NUM_INLET_CALIB_BLOCKS ) )

#define N2_AUTO_CAL_OFFSET            ( INLET_AUTO_CAL_START )
#define H2_AUTO_CAL_OFFSET            ( N2_AUTO_CAL_OFFSET       + INLET_AUTO_CAL_BLOCK_SIZE )
#define He_AUTO_CAL_OFFSET            ( H2_AUTO_CAL_OFFSET       + INLET_AUTO_CAL_BLOCK_SIZE )
#define ArMe_AUTO_CAL_OFFSET          ( He_AUTO_CAL_OFFSET       + INLET_AUTO_CAL_BLOCK_SIZE )
#define Unused_AUTO_CAL_OFFSET_1      ( ArMe_AUTO_CAL_OFFSET     + INLET_AUTO_CAL_BLOCK_SIZE )
#define Unused_AUTO_CAL_OFFSET_2      ( Unused_AUTO_CAL_OFFSET_1 + INLET_AUTO_CAL_BLOCK_SIZE )




/**********************************************************************************************************/
/**********************************************************************************************************/
/* *                                                                                                    * */
/* *    Below this line, everyting is specific only to JILLs !                                          * */
/* *                                                                                                    * */
/* *                                                                                                    * */
/* *                                                                                                    * */
/* *                                                                                                    * */
/**********************************************************************************************************/
/**********************************************************************************************************/



/* now define the various gas blocks for inlets */

#define INLET_PRES_CALIB_SIZE        ( 3 * 4 )
#define INLET_PRES_CALIB_START       ( INLET_FLOW_CALIB_START + ( INLET_CALIB_BLOCK_SIZE * NUM_INLET_CALIB_BLOCKS ) )


#define INLET_PRES_CALIB_P1          ( INLET_PRES_CALIB_START )
#define INLET_PRES_CALIB_P2          ( INLET_PRES_CALIB_START + 1 )
#define INLET_PRES_CALIB_P3          ( INLET_PRES_CALIB_START + 2 )
#define INLET_PRES_CALIB_P4          ( INLET_PRES_CALIB_START + 3 )
#define INLET_PRES_CALIB_V_P1        ( INLET_PRES_CALIB_START + 4 )
#define INLET_PRES_CALIB_V_P2        ( INLET_PRES_CALIB_START + 5 )
#define INLET_PRES_CALIB_V_P3        ( INLET_PRES_CALIB_START + 6 )
#define INLET_PRES_CALIB_V_P4        ( INLET_PRES_CALIB_START + 7 )
#define INLET_PRES_CALIB_SPARE       ( INLET_PRES_CALIB_START + 8 )


/**********************************************************************************************************/
/**********************************************************************************************************/
/**********************************************************************************************************/



#define JILL_PID_START           ( IU_SCALE_START + IU_SCALE_SIZE )


/* now map out the start positions of the various blocks for */
/* the detector temp comp parameters                         */


#define JILL_PID_SIZE            ( 6 * PID_BLOCK_SIZE )   /* 3 channels * 6 gases per channel * 4 pids per channel */

#define J_PID_BLOCK1_START         ( JILL_PID_START  )
#define J_PID_BLOCK2_START         ( J_PID_BLOCK1_START + PID_BLOCK_SIZE )
#define J_PID_BLOCK3_START         ( J_PID_BLOCK2_START + PID_BLOCK_SIZE )
#define J_PID_BLOCK4_START         ( J_PID_BLOCK3_START + PID_BLOCK_SIZE )
#define J_PID_BLOCK5_START         ( J_PID_BLOCK4_START + PID_BLOCK_SIZE )
#define J_PID_BLOCK6_START         ( J_PID_BLOCK5_START + PID_BLOCK_SIZE )

/** Pres Channel **/


#define JILL_CH_1_N2_I_GAIN       ( J_PID_BLOCK1_START + PID_COL1 + I_GAIN )
#define JILL_CH_1_N2_P_GAIN       ( J_PID_BLOCK1_START + PID_COL1 + P_GAIN )
#define JILL_CH_1_N2_D_GAIN       ( J_PID_BLOCK1_START + PID_COL1 + D_GAIN )
#define JILL_CH_1_N2_NL_GAIN      ( J_PID_BLOCK1_START + PID_COL1 + NL_GAIN )

#define JILL_CH_1_H2_I_GAIN       ( J_PID_BLOCK2_START + PID_COL1 + I_GAIN )
#define JILL_CH_1_H2_P_GAIN       ( J_PID_BLOCK2_START + PID_COL1 + P_GAIN )
#define JILL_CH_1_H2_D_GAIN       ( J_PID_BLOCK2_START + PID_COL1 + D_GAIN )
#define JILL_CH_1_H2_NL_GAIN      ( J_PID_BLOCK2_START + PID_COL1 + NL_GAIN )

#define JILL_CH_1_He_I_GAIN       ( J_PID_BLOCK3_START + PID_COL1 + I_GAIN )
#define JILL_CH_1_He_P_GAIN       ( J_PID_BLOCK3_START + PID_COL1 + P_GAIN )
#define JILL_CH_1_He_D_GAIN       ( J_PID_BLOCK3_START + PID_COL1 + D_GAIN )
#define JILL_CH_1_He_NL_GAIN      ( J_PID_BLOCK3_START + PID_COL1 + NL_GAIN )

#define JILL_CH_1_ArMe_I_GAIN     ( J_PID_BLOCK4_START + PID_COL1 + I_GAIN )
#define JILL_CH_1_ArMe_P_GAIN     ( J_PID_BLOCK4_START + PID_COL1 + P_GAIN )
#define JILL_CH_1_ArMe_D_GAIN     ( J_PID_BLOCK4_START + PID_COL1 + D_GAIN )
#define JILL_CH_1_ArMe_NL_GAIN    ( J_PID_BLOCK4_START + PID_COL1 + NL_GAIN )

#define JILL_CH_1_O2_I_GAIN       ( J_PID_BLOCK5_START + PID_COL1 + I_GAIN )
#define JILL_CH_1_O2_P_GAIN       ( J_PID_BLOCK5_START + PID_COL1 + P_GAIN )
#define JILL_CH_1_O2_D_GAIN       ( J_PID_BLOCK5_START + PID_COL1 + D_GAIN )
#define JILL_CH_1_O2_NL_GAIN      ( J_PID_BLOCK5_START + PID_COL1 + NL_GAIN )

#define JILL_CH_1_Air_I_GAIN      ( J_PID_BLOCK6_START + PID_COL1 + I_GAIN )
#define JILL_CH_1_Air_P_GAIN      ( J_PID_BLOCK6_START + PID_COL1 + P_GAIN )
#define JILL_CH_1_Air_D_GAIN      ( J_PID_BLOCK6_START + PID_COL1 + D_GAIN )
#define JILL_CH_1_Air_NL_GAIN     ( J_PID_BLOCK6_START + PID_COL1 + NL_GAIN )


/** Flow channel **/

#define JILL_CH_2_N2_I_GAIN       ( J_PID_BLOCK1_START + PID_COL2 + I_GAIN )
#define JILL_CH_2_N2_P_GAIN       ( J_PID_BLOCK1_START + PID_COL2 + P_GAIN )
#define JILL_CH_2_N2_D_GAIN       ( J_PID_BLOCK1_START + PID_COL2 + D_GAIN )
#define JILL_CH_2_N2_NL_GAIN      ( J_PID_BLOCK1_START + PID_COL2 + NL_GAIN )

#define JILL_CH_2_H2_I_GAIN       ( J_PID_BLOCK2_START + PID_COL2 + I_GAIN )
#define JILL_CH_2_H2_P_GAIN       ( J_PID_BLOCK2_START + PID_COL2 + P_GAIN )
#define JILL_CH_2_H2_D_GAIN       ( J_PID_BLOCK2_START + PID_COL2 + D_GAIN )
#define JILL_CH_2_H2_NL_GAIN      ( J_PID_BLOCK2_START + PID_COL2 + NL_GAIN )

#define JILL_CH_2_He_I_GAIN       ( J_PID_BLOCK3_START + PID_COL2 + I_GAIN )
#define JILL_CH_2_He_P_GAIN       ( J_PID_BLOCK3_START + PID_COL2 + P_GAIN )
#define JILL_CH_2_He_D_GAIN       ( J_PID_BLOCK3_START + PID_COL2 + D_GAIN )
#define JILL_CH_2_He_NL_GAIN      ( J_PID_BLOCK3_START + PID_COL2 + NL_GAIN )

#define JILL_CH_2_ArMe_I_GAIN     ( J_PID_BLOCK4_START + PID_COL2 + I_GAIN )
#define JILL_CH_2_ArMe_P_GAIN     ( J_PID_BLOCK4_START + PID_COL2 + P_GAIN )
#define JILL_CH_2_ArMe_D_GAIN     ( J_PID_BLOCK4_START + PID_COL2 + D_GAIN )
#define JILL_CH_2_ArMe_NL_GAIN    ( J_PID_BLOCK4_START + PID_COL2 + NL_GAIN )

#define JILL_CH_2_O2_I_GAIN       ( J_PID_BLOCK5_START + PID_COL2 + I_GAIN )
#define JILL_CH_2_O2_P_GAIN       ( J_PID_BLOCK5_START + PID_COL2 + P_GAIN )
#define JILL_CH_2_O2_D_GAIN       ( J_PID_BLOCK5_START + PID_COL2 + D_GAIN )
#define JILL_CH_2_O2_NL_GAIN      ( J_PID_BLOCK5_START + PID_COL2 + NL_GAIN )

#define JILL_CH_2_Air_I_GAIN      ( J_PID_BLOCK6_START + PID_COL2 + I_GAIN )
#define JILL_CH_2_Air_P_GAIN      ( J_PID_BLOCK6_START + PID_COL2 + P_GAIN )
#define JILL_CH_2_Air_D_GAIN      ( J_PID_BLOCK6_START + PID_COL2 + D_GAIN )
#define JILL_CH_2_Air_NL_GAIN     ( J_PID_BLOCK6_START + PID_COL2 + NL_GAIN )




/** Alt channel **/

#define JILL_CH_3_N2_I_GAIN       ( J_PID_BLOCK1_START + PID_COL3 + I_GAIN )
#define JILL_CH_3_N2_P_GAIN       ( J_PID_BLOCK1_START + PID_COL3 + P_GAIN )
#define JILL_CH_3_N2_D_GAIN       ( J_PID_BLOCK1_START + PID_COL3 + D_GAIN )
#define JILL_CH_3_N2_NL_GAIN      ( J_PID_BLOCK1_START + PID_COL3 + NL_GAIN )

#define JILL_CH_3_H2_I_GAIN       ( J_PID_BLOCK2_START + PID_COL3 + I_GAIN )
#define JILL_CH_3_H2_P_GAIN       ( J_PID_BLOCK2_START + PID_COL3 + P_GAIN )
#define JILL_CH_3_H2_D_GAIN       ( J_PID_BLOCK2_START + PID_COL3 + D_GAIN )
#define JILL_CH_3_H2_NL_GAIN      ( J_PID_BLOCK2_START + PID_COL3 + NL_GAIN )

#define JILL_CH_3_He_I_GAIN       ( J_PID_BLOCK3_START + PID_COL3 + I_GAIN )
#define JILL_CH_3_He_P_GAIN       ( J_PID_BLOCK3_START + PID_COL3 + P_GAIN )
#define JILL_CH_3_He_D_GAIN       ( J_PID_BLOCK3_START + PID_COL3 + D_GAIN )
#define JILL_CH_3_He_NL_GAIN      ( J_PID_BLOCK3_START + PID_COL3 + NL_GAIN )

#define JILL_CH_3_ArMe_I_GAIN     ( J_PID_BLOCK4_START + PID_COL3 + I_GAIN )
#define JILL_CH_3_ArMe_P_GAIN     ( J_PID_BLOCK4_START + PID_COL3 + P_GAIN )
#define JILL_CH_3_ArMe_D_GAIN     ( J_PID_BLOCK4_START + PID_COL3 + D_GAIN )
#define JILL_CH_3_ArMe_NL_GAIN    ( J_PID_BLOCK4_START + PID_COL3 + NL_GAIN )

#define JILL_CH_3_O2_I_GAIN       ( J_PID_BLOCK5_START + PID_COL3 + I_GAIN )
#define JILL_CH_3_O2_P_GAIN       ( J_PID_BLOCK5_START + PID_COL3 + P_GAIN )
#define JILL_CH_3_O2_D_GAIN       ( J_PID_BLOCK5_START + PID_COL3 + D_GAIN )
#define JILL_CH_3_O2_NL_GAIN      ( J_PID_BLOCK5_START + PID_COL3 + NL_GAIN )

#define JILL_CH_3_Air_I_GAIN      ( J_PID_BLOCK6_START + PID_COL3 + I_GAIN )
#define JILL_CH_3_Air_P_GAIN      ( J_PID_BLOCK6_START + PID_COL3 + P_GAIN )
#define JILL_CH_3_Air_D_GAIN      ( J_PID_BLOCK6_START + PID_COL3 + D_GAIN )
#define JILL_CH_3_Air_NL_GAIN     ( J_PID_BLOCK6_START + PID_COL3 + NL_GAIN )



/**********************************************************************************************************/
/**********************************************************************************************************/
/**********************************************************************************************************/

#define JILL_TEMP_COMP_START              ( JILL_PID_START + JILL_PID_SIZE )

/* now define the various gas blocks for inlets */

#define NUM_JILL_INLET_BLOCKS             ( 6 )

#define JILL_H2_BLOCK                     ( JILL_TEMP_COMP_START )
#define JILL_HE_BLOCK                     ( JILL_H2_BLOCK   + INLET_BLOCK_SIZE )
#define JILL_ARME_BLOCK                   ( JILL_HE_BLOCK   + INLET_BLOCK_SIZE )
#define JILL_N2_BLOCK                     ( JILL_ARME_BLOCK + INLET_BLOCK_SIZE )
#define JILL_AIR_BLOCK                    ( JILL_N2_BLOCK   + INLET_BLOCK_SIZE )
#define JILL_O2_BLOCK                     ( JILL_AIR_BLOCK  + INLET_BLOCK_SIZE )


  /* inlet specific temp comp parms */

#define JILL_H2_ALPHA_LOW                 ( JILL_H2_BLOCK + ALPHA_LOW   )
#define JILL_H2_ALPHA_HIGH                ( JILL_H2_BLOCK + ALPHA_HIGH  )
#define JILL_H2_BETA_LOW                  ( JILL_H2_BLOCK + BETA_LOW    )
#define JILL_H2_BETA_HIGH                 ( JILL_H2_BLOCK + BETA_HIGH   )
#define JILL_H2_OFFSET                    ( JILL_H2_BLOCK + OFFSET      )
#define JILL_H2_HIGH_FLOW                 ( JILL_H2_BLOCK + SWITCH_FLOW )
#define JILL_H2_dALPHA_dT                 ( JILL_H2_BLOCK + DALPHA      )
#define JILL_H2_dBETA_dT                  ( JILL_H2_BLOCK + DBETA       )
#define JILL_H2_dOFFSET_dT                ( JILL_H2_BLOCK + DOFFSET     )
#define JILL_H2_REF_TEMP                  ( JILL_H2_BLOCK + REF_TEMP    )
#define JILL_H2_PURGE_FLOW                ( JILL_H2_BLOCK + PURGE_REG_FLOW )
#define JILL_H2_dPURGE_dP                 ( JILL_H2_BLOCK + DPURGE_FLOW_DPRES )
#define JILL_H2_MAX_INLET_FLOW            ( JILL_H2_BLOCK + MAX_INLET_FLOW    )
#define JILL_H2_CALIB_TEMP_1              ( JILL_H2_BLOCK + CALIB_TEMP_1)
#define JILL_H2_CALIB_TEMP_2              ( JILL_H2_BLOCK + CALIB_TEMP_2)

#define JILL_He_ALPHA_LOW                 ( JILL_HE_BLOCK + ALPHA_LOW   )
#define JILL_He_ALPHA_HIGH                ( JILL_HE_BLOCK + ALPHA_HIGH  )
#define JILL_He_BETA_LOW                  ( JILL_HE_BLOCK + BETA_LOW    )
#define JILL_He_BETA_HIGH                 ( JILL_HE_BLOCK + BETA_HIGH   )
#define JILL_He_OFFSET                    ( JILL_HE_BLOCK + OFFSET      )
#define JILL_He_HIGH_FLOW                 ( JILL_HE_BLOCK + SWITCH_FLOW )
#define JILL_He_dALPHA_dT                 ( JILL_HE_BLOCK + DALPHA      )
#define JILL_He_dBETA_dT                  ( JILL_HE_BLOCK + DBETA       )
#define JILL_He_dOFFSET_dT                ( JILL_HE_BLOCK + DOFFSET     )
#define JILL_He_REF_TEMP                  ( JILL_HE_BLOCK + REF_TEMP    )
#define JILL_He_PURGE_FLOW                ( JILL_HE_BLOCK + PURGE_REG_FLOW )
#define JILL_He_dPURGE_dP                 ( JILL_HE_BLOCK + DPURGE_FLOW_DPRES )
#define JILL_He_MAX_INLET_FLOW            ( JILL_HE_BLOCK + MAX_INLET_FLOW    )
#define JILL_He_CALIB_TEMP_1              ( JILL_HE_BLOCK + CALIB_TEMP_1)
#define JILL_He_CALIB_TEMP_2              ( JILL_HE_BLOCK + CALIB_TEMP_2)

#define JILL_N2_ALPHA_LOW                 ( JILL_N2_BLOCK + ALPHA_LOW   )
#define JILL_N2_ALPHA_HIGH                ( JILL_N2_BLOCK + ALPHA_HIGH  )
#define JILL_N2_BETA_LOW                  ( JILL_N2_BLOCK + BETA_LOW    )
#define JILL_N2_BETA_HIGH                 ( JILL_N2_BLOCK + BETA_HIGH   )
#define JILL_N2_OFFSET                    ( JILL_N2_BLOCK + OFFSET      )
#define JILL_N2_HIGH_FLOW                 ( JILL_N2_BLOCK + SWITCH_FLOW )
#define JILL_N2_dALPHA_dT                 ( JILL_N2_BLOCK + DALPHA      )
#define JILL_N2_dBETA_dT                  ( JILL_N2_BLOCK + DBETA       )
#define JILL_N2_dOFFSET_dT                ( JILL_N2_BLOCK + DOFFSET     )
#define JILL_N2_REF_TEMP                  ( JILL_N2_BLOCK + REF_TEMP    )
#define JILL_N2_PURGE_FLOW                ( JILL_N2_BLOCK + PURGE_REG_FLOW )
#define JILL_N2_dPURGE_dP                 ( JILL_N2_BLOCK + DPURGE_FLOW_DPRES )
#define JILL_N2_MAX_INLET_FLOW            ( JILL_N2_BLOCK + MAX_INLET_FLOW    )
#define JILL_N2_CALIB_TEMP_1              ( JILL_N2_BLOCK + CALIB_TEMP_1)
#define JILL_N2_CALIB_TEMP_2              ( JILL_N2_BLOCK + CALIB_TEMP_2)

#define JILL_ArMe_ALPHA_LOW               ( JILL_ARME_BLOCK + ALPHA_LOW   )
#define JILL_ArMe_ALPHA_HIGH              ( JILL_ARME_BLOCK + ALPHA_HIGH  )
#define JILL_ArMe_BETA_LOW                ( JILL_ARME_BLOCK + BETA_LOW    )
#define JILL_ArMe_BETA_HIGH               ( JILL_ARME_BLOCK + BETA_HIGH   )
#define JILL_ArMe_OFFSET                  ( JILL_ARME_BLOCK + OFFSET      )
#define JILL_ArMe_HIGH_FLOW               ( JILL_ARME_BLOCK + SWITCH_FLOW )
#define JILL_ArMe_dALPHA_dT               ( JILL_ARME_BLOCK + DALPHA      )
#define JILL_ArMe_dBETA_dT                ( JILL_ARME_BLOCK + DBETA       )
#define JILL_ArMe_dOFFSET_dT              ( JILL_ARME_BLOCK + DOFFSET     )
#define JILL_ArMe_REF_TEMP                ( JILL_ARME_BLOCK + REF_TEMP    )
#define JILL_ArMe_PURGE_FLOW              ( JILL_ARME_BLOCK + PURGE_REG_FLOW )
#define JILL_ArMe_dPURGE_dP               ( JILL_ARME_BLOCK + DPURGE_FLOW_DPRES )
#define JILL_ArMe_MAX_INLET_FLOW          ( JILL_ARME_BLOCK + MAX_INLET_FLOW    )
#define JILL_ArMe_CALIB_TEMP_1            ( JILL_ARME_BLOCK + CALIB_TEMP_1)
#define JILL_ArMe_CALIB_TEMP_2            ( JILL_ARME_BLOCK + CALIB_TEMP_2)

#define JILL_Air_ALPHA_LOW                ( JILL_AIR_BLOCK + ALPHA_LOW   )
#define JILL_Air_ALPHA_HIGH               ( JILL_AIR_BLOCK + ALPHA_HIGH  )
#define JILL_Air_BETA_LOW                 ( JILL_AIR_BLOCK + BETA_LOW    )
#define JILL_Air_BETA_HIGH                ( JILL_AIR_BLOCK + BETA_HIGH   )
#define JILL_Air_OFFSET                   ( JILL_AIR_BLOCK + OFFSET      )
#define JILL_Air_HIGH_FLOW                ( JILL_AIR_BLOCK + SWITCH_FLOW )
#define JILL_Air_dALPHA_dT                ( JILL_AIR_BLOCK + DALPHA      )
#define JILL_Air_dBETA_dT                 ( JILL_AIR_BLOCK + DBETA       )
#define JILL_Air_dOFFSET_dT               ( JILL_AIR_BLOCK + DOFFSET     )
#define JILL_Air_REF_TEMP                 ( JILL_AIR_BLOCK + REF_TEMP    )
#define JILL_Air_PURGE_FLOW               ( JILL_AIR_BLOCK + PURGE_REG_FLOW )
#define JILL_Air_dPURGE_dP                ( JILL_AIR_BLOCK + DPURGE_FLOW_DPRES )
#define JILL_Air_MAX_INLET_FLOW           ( JILL_AIR_BLOCK + MAX_INLET_FLOW    )
#define JILL_Air_CALIB_TEMP_1             ( JILL_AIR_BLOCK + CALIB_TEMP_1)
#define JILL_Air_CALIB_TEMP_2             ( JILL_AIR_BLOCK + CALIB_TEMP_2)

#define JILL_O2_ALPHA_LOW                 ( JILL_O2_BLOCK + ALPHA_LOW   )
#define JILL_O2_ALPHA_HIGH                ( JILL_O2_BLOCK + ALPHA_HIGH  )
#define JILL_O2_BETA_LOW                  ( JILL_O2_BLOCK + BETA_LOW    )
#define JILL_O2_BETA_HIGH                 ( JILL_O2_BLOCK + BETA_HIGH   )
#define JILL_O2_OFFSET                    ( JILL_O2_BLOCK + OFFSET      )
#define JILL_O2_HIGH_FLOW                 ( JILL_O2_BLOCK + SWITCH_FLOW )
#define JILL_O2_dALPHA_dT                 ( JILL_O2_BLOCK + DALPHA      )
#define JILL_O2_dBETA_dT                  ( JILL_O2_BLOCK + DBETA       )
#define JILL_O2_dOFFSET_dT                ( JILL_O2_BLOCK + DOFFSET     )
#define JILL_O2_REF_TEMP                  ( JILL_O2_BLOCK + REF_TEMP    )
#define JILL_O2_PURGE_FLOW                ( JILL_O2_BLOCK + PURGE_REG_FLOW )
#define JILL_O2_dPURGE_dP                 ( JILL_O2_BLOCK + DPURGE_FLOW_DPRES )
#define JILL_O2_MAX_INLET_FLOW            ( JILL_O2_BLOCK + MAX_INLET_FLOW    )
#define JILL_O2_CALIB_TEMP_1              ( JILL_O2_BLOCK + CALIB_TEMP_1)
#define JILL_O2_CALIB_TEMP_2              ( JILL_O2_BLOCK + CALIB_TEMP_2)



/**********************************************************************************************************/
/**********************************************************************************************************/
/**********************************************************************************************************/


/* now define the various gas blocks for inlets */

#define JILL_INLET_CALIB_BLOCK_SIZE        ( 3 * 3 )
#define JILL_NUM_INLET_CALIB_BLOCKS          6

#define JILL_INLET_FLOW_CALIB_START         ( JILL_TEMP_COMP_START +( INLET_BLOCK_SIZE * NUM_JILL_INLET_BLOCKS ) )

#define JILL_H2_CALIB_BLOCK                     ( JILL_INLET_FLOW_CALIB_START )
#define JILL_He_CALIB_BLOCK                     ( JILL_H2_CALIB_BLOCK   + INLET_CALIB_BLOCK_SIZE )
#define JILL_ArMe_CALIB_BLOCK                   ( JILL_He_CALIB_BLOCK   + INLET_CALIB_BLOCK_SIZE )
#define JILL_N2_CALIB_BLOCK                     ( JILL_ArMe_CALIB_BLOCK + INLET_CALIB_BLOCK_SIZE )
#define JILL_Air_CALIB_BLOCK                    ( JILL_N2_CALIB_BLOCK   + INLET_CALIB_BLOCK_SIZE )
#define JILL_O2_CALIB_BLOCK                     ( JILL_Air_CALIB_BLOCK  + INLET_CALIB_BLOCK_SIZE )

   /* these values are for jill */

#define CALIB_FLOW       ( 0 )
#define CALIB_V1         ( 1 )
#define CALIB_V2         ( 2 )
#define CALIB_V3         ( 3 )
#define CALIB_V4         ( 4 )
#define CALIB_V5         ( 5 )
#define CALIB_V6         ( 6 )
#define CALIB_V7         ( 7 )
#define CALIB_V8         ( 8 )



#define JILL_H2_CALIB_REF_FLOW             ( JILL_H2_CALIB_BLOCK + CALIB_FLOW )
#define JILL_H2_CALIB_V1                   ( JILL_H2_CALIB_BLOCK + CALIB_V1 )
#define JILL_H2_CALIB_V2                   ( JILL_H2_CALIB_BLOCK + CALIB_V2 )
#define JILL_H2_CALIB_V3                   ( JILL_H2_CALIB_BLOCK + CALIB_V3 )
#define JILL_H2_CALIB_V4                   ( JILL_H2_CALIB_BLOCK + CALIB_V4 )
#define JILL_H2_CALIB_V5                   ( JILL_H2_CALIB_BLOCK + CALIB_V5 )
#define JILL_H2_CALIB_V6                   ( JILL_H2_CALIB_BLOCK + CALIB_V6 )
#define JILL_H2_CALIB_V7                   ( JILL_H2_CALIB_BLOCK + CALIB_V7 )
#define JILL_H2_CALIB_V8                   ( JILL_H2_CALIB_BLOCK + CALIB_V8 )

#define JILL_He_CALIB_REF_FLOW             ( JILL_He_CALIB_BLOCK + CALIB_FLOW )
#define JILL_He_CALIB_V1                   ( JILL_He_CALIB_BLOCK + CALIB_V1 )
#define JILL_He_CALIB_V2                   ( JILL_He_CALIB_BLOCK + CALIB_V2 )
#define JILL_He_CALIB_V3                   ( JILL_He_CALIB_BLOCK + CALIB_V3 )
#define JILL_He_CALIB_V4                   ( JILL_He_CALIB_BLOCK + CALIB_V4 )
#define JILL_He_CALIB_V5                   ( JILL_He_CALIB_BLOCK + CALIB_V5 )
#define JILL_He_CALIB_V6                   ( JILL_He_CALIB_BLOCK + CALIB_V6 )
#define JILL_He_CALIB_V7                   ( JILL_He_CALIB_BLOCK + CALIB_V7 )
#define JILL_He_CALIB_V8                   ( JILL_He_CALIB_BLOCK + CALIB_V8 )

#define JILL_ArMe_CALIB_REF_FLOW           ( JILL_ArMe_CALIB_BLOCK + CALIB_FLOW )
#define JILL_ArMe_CALIB_V1                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V1 )
#define JILL_ArMe_CALIB_V2                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V2 )
#define JILL_ArMe_CALIB_V3                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V3 )
#define JILL_ArMe_CALIB_V4                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V4 )
#define JILL_ArMe_CALIB_V5                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V5 )
#define JILL_ArMe_CALIB_V6                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V6 )
#define JILL_ArMe_CALIB_V7                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V7 )
#define JILL_ArMe_CALIB_V8                 ( JILL_ArMe_CALIB_BLOCK + CALIB_V8 )

#define JILL_N2_CALIB_REF_FLOW             ( JILL_N2_CALIB_BLOCK + CALIB_FLOW )
#define JILL_N2_CALIB_V1                   ( JILL_N2_CALIB_BLOCK + CALIB_V1 )
#define JILL_N2_CALIB_V2                   ( JILL_N2_CALIB_BLOCK + CALIB_V2 )
#define JILL_N2_CALIB_V3                   ( JILL_N2_CALIB_BLOCK + CALIB_V3 )
#define JILL_N2_CALIB_V4                   ( JILL_N2_CALIB_BLOCK + CALIB_V4 )
#define JILL_N2_CALIB_V5                   ( JILL_N2_CALIB_BLOCK + CALIB_V5 )
#define JILL_N2_CALIB_V6                   ( JILL_N2_CALIB_BLOCK + CALIB_V6 )
#define JILL_N2_CALIB_V7                   ( JILL_N2_CALIB_BLOCK + CALIB_V7 )
#define JILL_N2_CALIB_V8                   ( JILL_N2_CALIB_BLOCK + CALIB_V8 )

#define JILL_Air_CALIB_REF_FLOW            ( JILL_Air_CALIB_BLOCK + CALIB_FLOW )
#define JILL_Air_CALIB_V1                  ( JILL_Air_CALIB_BLOCK + CALIB_V1 )
#define JILL_Air_CALIB_V2                  ( JILL_Air_CALIB_BLOCK + CALIB_V2 )
#define JILL_Air_CALIB_V3                  ( JILL_Air_CALIB_BLOCK + CALIB_V3 )
#define JILL_Air_CALIB_V4                  ( JILL_Air_CALIB_BLOCK + CALIB_V4 )
#define JILL_Air_CALIB_V5                  ( JILL_Air_CALIB_BLOCK + CALIB_V5 )
#define JILL_Air_CALIB_V6                  ( JILL_Air_CALIB_BLOCK + CALIB_V6 )
#define JILL_Air_CALIB_V7                  ( JILL_Air_CALIB_BLOCK + CALIB_V7 )
#define JILL_Air_CALIB_V8                  ( JILL_Air_CALIB_BLOCK + CALIB_V8 )

#define JILL_O2_CALIB_REF_FLOW             ( JILL_O2_CALIB_BLOCK + CALIB_FLOW )
#define JILL_O2_CALIB_V1                   ( JILL_O2_CALIB_BLOCK + CALIB_V1 )
#define JILL_O2_CALIB_V2                   ( JILL_O2_CALIB_BLOCK + CALIB_V2 )
#define JILL_O2_CALIB_V3                   ( JILL_O2_CALIB_BLOCK + CALIB_V3 )
#define JILL_O2_CALIB_V4                   ( JILL_O2_CALIB_BLOCK + CALIB_V4 )
#define JILL_O2_CALIB_V5                   ( JILL_O2_CALIB_BLOCK + CALIB_V5 )
#define JILL_O2_CALIB_V6                   ( JILL_O2_CALIB_BLOCK + CALIB_V6 )
#define JILL_O2_CALIB_V7                   ( JILL_O2_CALIB_BLOCK + CALIB_V7 )
#define JILL_O2_CALIB_V8                   ( JILL_O2_CALIB_BLOCK + CALIB_V8 )

/**********************************************************************************************************/
/**********************************************************************************************************/
/**********************************************************************************************************/



/* now define the various gas blocks for inlets */

#define JILL_INLET_PRES_CALIB_START       ( JILL_INLET_FLOW_CALIB_START + ( INLET_CALIB_BLOCK_SIZE * JILL_NUM_INLET_CALIB_BLOCKS ) )


#define JILL_INLET_PRES_CALIB_P1          ( JILL_INLET_PRES_CALIB_START )
#define JILL_INLET_PRES_CALIB_P2          ( JILL_INLET_PRES_CALIB_START + 1 )
#define JILL_INLET_PRES_CALIB_P3          ( JILL_INLET_PRES_CALIB_START + 2 )
#define JILL_INLET_PRES_CALIB_P4          ( JILL_INLET_PRES_CALIB_START + 3 )
#define JILL_INLET_PRES_CALIB_V_P1        ( JILL_INLET_PRES_CALIB_START + 4 )
#define JILL_INLET_PRES_CALIB_V_P2        ( JILL_INLET_PRES_CALIB_START + 5 )
#define JILL_INLET_PRES_CALIB_V_P3        ( JILL_INLET_PRES_CALIB_START + 6 )
#define JILL_INLET_PRES_CALIB_V_P4        ( JILL_INLET_PRES_CALIB_START + 7 )
#define JILL_INLET_PRES_CALIB_SPARE       ( JILL_INLET_PRES_CALIB_START + 8 )





/*****************************/
/*   MACROS                  */
/*****************************/


/*****************************/
/*   TYPEDEFS                */
/*****************************/


/*****************************/
/*   FUNCTION PROTOTYPES     */
/*****************************/

#endif
